<template lang="html">
  <el-dialog  :close-on-click-modal="closeonclickmodal"  title="新增系统权限点" @open="listenopen()" @close="close" :visible="dialogshow">
    <el-form  :model="dialoginfo" ref="dialoginfo" label-position="left">
      <el-row>
        <el-col :span="10">
          <el-form-item  label="权限名称" :label-width="formLabelWidth">
            <el-input disabled v-model="dialoginfo.name" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item label="映射路径" :label-width="formLabelWidth">
            <el-input disabled  v-model="dialoginfo.url" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item label="HTTP类型" :label-width="formLabelWidth">
            <el-input disabled  v-model="dialoginfo.httpMethod" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item label="类方法名" :label-width="formLabelWidth">
            <el-input  disabled v-model="dialoginfo.methodName" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item label="类包名" :label-width="formLabelWidth">
            <el-input  disabled v-model="dialoginfo.className" auto-complete="off" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="2">&nbsp;</el-col>
        <el-col :span="10">
          <el-form-item
            :rules="[
                      { required: true, message: '不能为空'}
                    ]"
            prop="desc"
            label="权限说明" :label-width="formLabelWidth">
            <el-input   v-model="dialoginfo.desc" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item  :rules="[
                      { required: true, message: '必须选择一样'}
                    ]" prop="type" label="权限类型" :label-width="formLabelWidth">
            <el-select v-model="dialoginfo.type" placeholder="请选择">
              <el-option label="按钮" :value="2"></el-option>
              <el-option label="菜单" :value="1"></el-option>
              <el-option label="其他" :value="3"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="权限组" :label-width="formLabelWidth">
            <el-input  v-model="dialoginfo.group" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item label="序号" :label-width="formLabelWidth">
            <el-input  v-model="dialoginfo.sort" auto-complete="off" clearable></el-input>
          </el-form-item>
          <el-form-item :rules="[
                      { required: true, message: '必须选择一样'}
                    ]" prop="open" label="是否公开" :label-width="formLabelWidth">
            <el-switch
              v-model="dialoginfo.open"
              active-color="#13ce66"
              inactive-color="#ff4949">
            </el-switch>
          </el-form-item>
          <el-form-item :rules="[
                      { required: true, message: '必须选择一项'}
                    ]" prop="state" label="状态" :label-width="formLabelWidth">
            <el-select v-model="dialoginfo.state" placeholder="请选择">
              <el-option label="启用" :value="1"></el-option>
              <el-option label="禁用" :value="0"></el-option>
              <el-option label="登陆可用" :value="2"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="2">&nbsp;</el-col>
      </el-row>
      <el-row>
        <el-form-item style="text-align: right">
          <el-button size="mini" @click="dialogshow = false">取 消</el-button>
          <el-button size="mini" type="primary" @click="toaddPerm('dialoginfo')">确 定</el-button>
        </el-form-item>
      </el-row>
    </el-form>
    <!--<div slot="footer" class="dialog-footer">-->
    <!--<el-button @click="dialogshow = false">取 消</el-button>-->
    <!--<el-button type="primary" @click="toaddPerm('form1')">确 定</el-button>-->
    <!--</div>-->
  </el-dialog>
</template>
<script>
  import {Message} from "element-ui"
  export default {
    inject:["reload"],
    data() {
      return {
        isajax:false,
        closeonclickmodal:false,
        formLabelWidth: '80px'
      }
    },
    props:['dialogshow','dialoginfo','isadd'],
    methods:{
      listenopen(){
        // console.log(this.dialogshow);
      },
      close(){
        this.$emit('changedialogshow')
        // console.log(this.dialogshow);
      },
      toaddPerm(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.isajax=true;
            this.proAPI.postJson(this.proAPI.URLS.addSysPerm,this.dialoginfo).then((res) =>{
              if(res!=null){
                Message.success({
                  "message":res.message
                })
                setTimeout(()=>{
                  this.reload();
                },1000)
              }else{
                // console.log(1233333);
                this.isajax=false;
              }
            });
          }else{
            return false;
          }
        });

      }
    },
    updated(){
      // console.log(333);
    }
  };
</script>
<style lang="css">
</style>
